const multer = require('multer')
// const upload = multer({ dest: './public/uploads/' })

const storage = multer.diskStorage({
    destination: function (req, file, cb) {
      cb(null, './public/uploads')
    },
    filename: function (req, file, cb) {
      
        let originalName = file.originalname;
        let ext = originalName.split('.');
        ext= ext[ext.length-1]
      cb(null, file.fieldname + '-' + Date.now()+'.'+ext)
    }
  })
   
const upload = multer({ storage: storage })

module.exports = upload